module dogre.mesh;

import dogre.sharedptr;
import dogre.internals.utils;

extern(C)
{
    void* call_MeshPtr_getPointer(void* ptr);
    void call_MeshPtr_bind(void* ptr, void* rep, SharedPtrFreeMethod freeMethod);
    bool call_MeshPtr_unique(void* ptr);
}

class Mesh
{
    //alias MeshPtr this;   <- Should that be there?
    
    mixin(Wrapper);
}

class MeshPtr
{
    mixin(Wrapper);
    
    alias the_mesh this;
    Mesh* getPointer()  //For compatibility with C++.
    {
        Mesh ptr = new Mesh(call_MeshPtr_getPointer(p));
        Mesh* ret = &ptr;
        return ret;
    }
    
    //for the alias this mainly
    private @property Mesh the_mesh()
    {
        return new Mesh(call_MeshPtr_getPointer(p));
    }
    
    Mesh opUnary(string s)() if (s == "&")
    {
        return new Mesh(call_MeshPtr_getPointer(p));
    }
    
    void bind(Mesh rep, SharedPtrFreeMethod freeMethod)
    {
        call_MeshPtr_bind(p, rep.p, freeMethod);
    }
    
    bool unique()
    {
        return call_MeshPtr_unique(p);
    }
}